package reflectionXmlExIm;


import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class ToXmlExporter {

	
	
	void exportToXml(Object o) throws ParserConfigurationException, TransformerException, IOException{
	    File outFile = new File("D:\\step\\files\\Output.xml");
	    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	    DocumentBuilder builder = factory.newDocumentBuilder();
	    Document doc = builder.newDocument();
	    Element root = doc.createElement("root");
	    doc.appendChild(root);
	    
	    
	    //Write to XML file
		TransformerFactory tFactory = TransformerFactory.newInstance();
		Transformer tr = tFactory.newTransformer();
		tr.transform(new DOMSource(doc),new StreamResult(outFile) );
	    
	}
}
